package com.wangzhen.spring.ioc.lifecycle.initializing;

import com.wangzhen.spring.ioc.dependcy.entity.Terminate;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;

public class MyDestructionAwareBeanPostProcessorDemo implements DestructionAwareBeanPostProcessor {
    @Override
    public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
        if ("terminate".equals(bean) || Terminate.class == bean.getClass()) {
            Terminate terminate = Terminate.class.cast(bean);
            terminate.setWhoAmI("whoAmI 555 from postProcessBeforeDestruction method");
            System.out.println(terminate);
        }
    }
}
